package cn.com.surker.sale.service.impl;

import cn.com.surker.sale.entity.SaleClientOrg;
import cn.com.surker.sale.dao.SaleClientOrgDao;
import cn.com.surker.sale.service.SaleClientOrgService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import cn.com.surker.spring.RestResultDto;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;

import javax.annotation.Resource;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

/**
 * <p>
 * 销售客户站点关联表 服务实现类
 * </p>
 *
 * @author admin
 * @since 2024-06-18
 */
@Service
public class SaleClientOrgServiceImpl extends ServiceImpl<SaleClientOrgDao, SaleClientOrg> implements SaleClientOrgService {

	@Resource
	private SaleClientOrgDao saleClientOrgDao;

	@Override
	public SaleClientOrg queryData(Long clientId, Long orgId, Integer type, Integer status) {
		List<SaleClientOrg> saleClientOrgs = queryList(clientId, orgId, type, status);
		if (saleClientOrgs != null && saleClientOrgs.size() > 0) {
			return saleClientOrgs.get(0);
		}
		return null;
	}

	@Override
	public List<SaleClientOrg> queryList(Long clientId, Long orgId, Integer type, Integer status) {
		QueryWrapper<SaleClientOrg> qw = new QueryWrapper<>();
		if (clientId != null) {
			qw.eq("client_id", clientId);
		}
		if (orgId != null) {
			qw.eq("org_id", orgId);
		}
		if (type != null) {
			qw.eq("type", type);
		}
		if (status != null) {
			qw.eq("status", status);
		}
		List<SaleClientOrg> saleClientOrgs = saleClientOrgDao.selectList(qw);
		return saleClientOrgs;
	}
}